WPS Office.apk(点击下载) / abjp.java


package defpackage;

import java.io.InputStream;
import java.io.Serializable;
import org.dom4j.DocumentFactory;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.XMLFilter;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

/* renamed from: abjp  reason: default package */
public final class abjp {
    private abjm CSE = new abjm();
    private DocumentFactory CSF;
    public abjj CSG;
    public boolean aSA;
    private String aSR = null;
    public boolean aTB = false;
    private XMLReader aTG;
    private boolean aTH;
    private boolean aTJ = true;
    private XMLFilter aTK;
    public EntityResolver aTq;
    private boolean aTt = false;
    private boolean aTu = false;
    public boolean aTx = false;
    private boolean aTz = false;
    private ErrorHandler errorHandler;

    /* renamed from: abjp$a */
    public static class a implements Serializable, EntityResolver {
        protected String aTL;

        public a(String str) {
            this.aTL = str;
        }

        @Override // org.xml.sax.EntityResolver
        public final InputSource resolveEntity(String str, String str2) {
            if (str2 != null && str2.length() > 0 && this.aTL != null && str2.indexOf(58) <= 0) {
                str2 = this.aTL + str2;
            }
            return new InputSource(str2);
        }
    }

    public abjp() {
    }

    public abjp(String str) throws SAXException {
        if (str != null) {
            this.aTG = XMLReaderFactory.createXMLReader(str);
        }
    }

    public abjp(String str, boolean z) throws SAXException {
        if (str != null) {
            this.aTG = XMLReaderFactory.createXMLReader(str);
        }
        this.aTH = z;
    }

    public abjp(DocumentFactory documentFactory) {
        this.CSF = documentFactory;
    }

    public abjp(DocumentFactory documentFactory, boolean z) {
        this.CSF = documentFactory;
        this.aTH = z;
    }

    public abjp(XMLReader xMLReader) {
        this.aTG = xMLReader;
    }

    public abjp(XMLReader xMLReader, boolean z) {
        this.aTG = xMLReader;
        this.aTH = z;
    }

    public abjp(boolean z) {
        this.aTH = z;
    }

    private abio d(InputSource inputSource) throws abip {
        int lastIndexOf;
        try {
            if (this.aTG == null) {
                this.aTG = abjo.cT(this.aTH);
            }
            XMLReader xMLReader = this.aTG;
            XMLFilter xMLFilter = this.aTK;
            if (xMLFilter != null) {
                XMLFilter xMLFilter2 = xMLFilter;
                while (true) {
                    XMLReader parent = xMLFilter2.getParent();
                    if (!(parent instanceof XMLFilter)) {
                        break;
                    }
                    xMLFilter2 = (XMLFilter) parent;
                }
                xMLFilter2.setParent(xMLReader);
                xMLReader = xMLFilter;
            }
            EntityResolver entityResolver = this.aTq;
            if (entityResolver == null) {
                String systemId = inputSource.getSystemId();
                entityResolver = new a((systemId == null || systemId.length() <= 0 || (lastIndexOf = systemId.lastIndexOf(47)) <= 0) ? null : systemId.substring(0, lastIndexOf + 1));
                this.aTq = entityResolver;
            }
            xMLReader.setEntityResolver(entityResolver);
            if (this.CSF == null) {
                this.CSF = DocumentFactory.hfO();
            }
            abjn abjn = new abjn(this.CSF, this.CSG, this.aSA);
            abjn.aTq = entityResolver;
            abjn.aTr = inputSource;
            abjn.CSE = this.CSE;
            boolean z = this.aTt;
            boolean z2 = this.aTu;
            abjn.aTt = z;
            abjn.aTu = z2;
            abjn.aTx = this.aTx;
            abjn.aTB = this.aTB;
            abjn.aTz = this.aTz;
            xMLReader.setContentHandler(abjn);
            abjo.a(xMLReader, "http://xml.org/sax/properties/lexical-handler", abjn);
            if (this.aTt || this.aTu) {
                abjo.a(xMLReader, "http://xml.org/sax/properties/declaration-handler", abjn);
            }
            abjo.a(xMLReader, "http://xml.org/sax/features/namespaces", true);
            abjo.a(xMLReader, "http://xml.org/sax/features/namespace-prefixes", false);
            abjo.a(xMLReader, "http://xml.org/sax/features/string-interning", this.aTJ);
            abjo.a(xMLReader, "http://xml.org/sax/features/use-locator2", true);
            try {
                xMLReader.setFeature("http://xml.org/sax/features/validation", this.aTH);
                if (this.errorHandler != null) {
                    xMLReader.setErrorHandler(this.errorHandler);
                } else {
                    xMLReader.setErrorHandler(abjn);
                }
            } catch (Exception e) {
                if (this.aTH) {
                    throw new abip("Validation not supported for XMLReader: " + xMLReader, e);
                }
            }
            xMLReader.parse(inputSource);
            return abjn.hfV();
        } catch (Exception e2) {
            if (e2 instanceof SAXParseException) {
                SAXParseException sAXParseException = (SAXParseException) e2;
                String systemId2 = sAXParseException.getSystemId();
                if (systemId2 == null) {
                    systemId2 = "";
                }
                throw new abip("Error on line " + sAXParseException.getLineNumber() + " of document " + systemId2 + " : " + sAXParseException.getMessage(), e2);
            } else if (e2 instanceof abjk) {
                return null;
            } else {
                throw new abip(e2.getMessage(), e2);
            }
        }
    }

    public final void a(String str, abis abis) {
        if (this.CSG == null) {
            this.CSG = new abjj();
        }
        this.CSG.a(str, abis);
    }

    public final abio as(InputStream inputStream) throws abip {
        InputSource inputSource = new InputSource(inputStream);
        if (this.aSR != null) {
            inputSource.setEncoding(this.aSR);
        }
        return d(inputSource);
    }
}